from django.contrib import admin
from .models import TherapyPlan, TherapyActivity, CBTExercise


@admin.register(TherapyPlan)
class TherapyPlanAdmin(admin.ModelAdmin):
    """疗愈方案管理"""
    list_display = ['id', 'user', 'plan_name', 'plan_type', 'target_emotion', 'start_date', 'progress', 'is_active']
    list_filter = ['plan_type', 'target_emotion', 'is_active', 'start_date']
    search_fields = ['user__username', 'plan_name']
    date_hierarchy = 'start_date'
    ordering = ['-created_at']


@admin.register(TherapyActivity)
class TherapyActivityAdmin(admin.ModelAdmin):
    """疗愈活动管理"""
    list_display = ['id', 'plan', 'activity_name', 'activity_type', 'scheduled_time', 'completed', 'effectiveness_rating']
    list_filter = ['activity_type', 'completed', 'scheduled_time']
    search_fields = ['activity_name', 'plan__plan_name']
    date_hierarchy = 'scheduled_time'
    ordering = ['scheduled_time']


@admin.register(CBTExercise)
class CBTExerciseAdmin(admin.ModelAdmin):
    """CBT练习管理"""
    list_display = ['id', 'user', 'emotion', 'exercise_date', 'created_at']
    list_filter = ['exercise_date', 'created_at']
    search_fields = ['user__username', 'situation', 'automatic_thought']
    date_hierarchy = 'exercise_date'
    ordering = ['-exercise_date', '-created_at']
